package com.googlecode.eightqueenshaggle;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class SolutionExplorerImageAdapter extends BaseAdapter {
    int mGalleryItemBackground;
    private Context mContext;

    private Integer[] mImageIds = {
            R.drawable.dot1,
            R.drawable.dot2,
            R.drawable.dot3,
            R.drawable.dot4,
            R.drawable.dot5,
    };

    public SolutionExplorerImageAdapter(Context c) {
        mContext = c;
        
        /*TypedArray a = obtainStyledAttributes(android.R.styleable.Theme);
        mGalleryItemBackground = a.getResourceId(
                android.R.styleable.Theme_galleryItemBackground, 0);
        a.recycle();*/
    }

    public int getCount() {
        return ((SolutionExplorerViewController)mContext).solObjArray.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);

        i.setImageResource(mImageIds[position % 5]);
        
        //We don't want scaling
        //i.setLayoutParams(new Gallery.LayoutParams(150, 100));
        
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setBackgroundResource(mGalleryItemBackground);

        return i;
    }
}